<?php

/**
 * 优惠信息
 * @author Ice <iceinto@mallog.com.cn>
 */
class LinkModel extends BaseModel
{
    /**
     * 获取首页友情链接
     * @return mixed
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function getHomeList()
    {
        $map = array();
        $map['level'] = 1;
        $map['status'] = 1;
        return $this->field('title,link_url')->order('list_order ASC')->limit('0,12')->where($map)->select();
    }

    /**
     * 根据类型获取链接列表
     * @return mixed
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function getTypeLinks()
    {
        $types = M('LinkType')->order('list_order ASC')->select();
        $map = array();
        foreach ($types as $key => $type) {
            $map['typeid'] = $type['itemid'];
            $map['status'] = 1;
            $types[$key]['links'] = $this->field('title,link_url')->order('list_order ASC')->where($map)->select();
        }
        return $types;
    }
}